package practice_0526;

import java.util.Arrays;

public class practice04_yieldAndJoin {
    public static void main(String[] args) throws InterruptedException {
            Person3 person = new Person3();
            person.setName("老韩");
            person.start();
            for (int i = 0; i < 20; i++) {
                System.out.println(Thread.currentThread().getName() +"吃了包子...." + i);
//                if(i == 5){
//                    System.out.println("老韩你先吃...");
//                    System.out.println(Thread.currentThread().getName() +"接着吃包子....");
//                }
            }

        }
    }

    class Person3 extends Thread {
        boolean loop = true;

        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                System.out.println(Thread.currentThread().getName() + "吃了包子" + i);
                if(i == 5){
                   Thread.yield();
                    System.out.println(Thread.currentThread().getName() + "让了一下..." );
                }
            }
        }

        public void setLoop(boolean loop) {
            this.loop = loop;
        }
    }
